package com.hefeng.wx.service.Impl;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hefeng.wx.domain.WxBanner;
import com.hefeng.wx.mapper.WxBannerMapper;
import com.hefeng.wx.service.WxBannerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * 轮播图信息表;(wx_banner)表服务实现类
 * @author : hzh
 * @date : 2022-9-5
 */
@Service
public class WxBannerServiceImpl extends ServiceImpl<WxBannerMapper, WxBanner> implements WxBannerService {
    @Autowired
    private WxBannerMapper wxBannerMapper;


    @Override
    public List<Map<String, Object>> getWxBannerList() {
        List<Map<String, Object>> bannerList=new ArrayList<>();
        bannerList=this.listMaps(Wrappers.lambdaQuery(new WxBanner()).select(WxBanner::getBannerId,WxBanner::getBannerTitle,WxBanner::getBannerImageUrl,WxBanner::getBannerTargetUrl,WxBanner::getBannerSort)
                .orderByAsc(WxBanner::getBannerSort).last("limit 3"));
        return bannerList;
    }

}